/**
 * 
 */
package com.thon.dao.user.impl;


import java.util.List;

import org.springframework.stereotype.Repository;

import com.thon.dao.user.UserBindDao;
import com.thon.dao.util.AbstractDao;
import com.thon.entity.user.UserBind;

/**
 * @file UserBindDaoImpl.java
 * @author Zemo
 * @email zemochen@lanbaoo.com
 * @date 2013年12月11日 上午10:29:21
 * @description TODO
 */
@Repository
public class UserBindDaoImpl extends AbstractDao<UserBind> implements UserBindDao{
	
	public UserBindDaoImpl(){
		super(UserBind.class);
	}

	@Override
	public UserBind getBind(String token) {
		
		/*String queryString ="select * from ym_user_binds where token like ?";// "FROM UserBind ub WHERE ub.token like ? ";
		token = "%" + token + "%";
		
		return findOneBySQL(queryString, token);*/
		
		String queryString = "FROM UserBind ub WHERE ub.token = ? ";
		//token = "%" + token + "%";
		
		return findOne(queryString,null, token);
	}

	@Override
	public UserBind getUserBind(Integer userId, Byte bindType) {
		
		String queryString = "FROM UserBind WHERE user.id = ? AND bindType = ?";
		return findOne(queryString, null, userId,bindType);
		
	}

	@Override
	public List<UserBind> listUserBinds(Integer userId) {
		
		String queryString = "FROM UserBind WHERE user.id = ?";
		return findList(queryString, null, userId);
	}
}
